package com.atguigu.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

/**
 * 跟my_index索引库文档映射
 * @author: atguigu
 * @create: 2023-12-12 14:17
 */
@Document(indexName = "product")  //默认扫描后自动创建索引
public class Product {

    @Override
    public String toString() {
        return "Product{" +
                "id='" + id + '\'' +
                ", title='" + title + '\'' +
                ", brand='" + brand + '\'' +
                ", desc='" + desc + '\'' +
                ", price=" + price +
                ", image='" + image + '\'' +
                '}';
    }

    @Id
    private String id;

    /**
     * 商品名称 对商品标题进行全文查询（多关键字分词查询） text ik
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String title;

    /**
     * 商品品牌 不分词，对品牌进行精确查询  keyword
     */
    @Field(type = FieldType.Keyword)
    private String brand;

    /**
     * 商品描述 对商品标题进行全文查询（多关键字分词查询） text ik
     */
    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String desc;


    @Field(type = FieldType.Long)
    private Long price;


    /**
     * 图片：不需分词，也不会用于查询
     */
    @Field(type = FieldType.Keyword, index = false)
    private String image;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Long getPrice() {
        return price;
    }

    public void setPrice(Long price) {
        this.price = price;
    }
}
